package cn.kgc.springbootday04.controller;

import cn.kgc.springbootday04.entity.Student;
import cn.kgc.springbootday04.service.StudentService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/5/30
 * @Description:
 */
@RestController
@RequestMapping("student")
public class StudentController {

    @Resource
    private StudentService studentService;




    @GetMapping
    public List<Student> getList(){

        List<Student> list = studentService.list();
        return list;
    }

    @GetMapping("delete")
    public String delete(Integer id){
        boolean b = studentService.removeById(id);
        return b+"";
    }


    @GetMapping("getById")
    public Student getById(Integer id){
      return  studentService.getById(id);
    }


}
